﻿function maline(from, to, d3mJS) {
	from.y = from.y * 3 - 15;
	to.y = to.y * 3 - 15;
	var itemLine = new ItemLine(0xff00ff);
	itemLine.addTo(d3mJS);
	itemLine.align(from, to);
}
function a1() {
	console.log("a1 init");
	var d3mJS = new D3mJS();
	d3mJS.init();

	var itemXYZ = new ItemXYZ();
	itemXYZ.addTo(d3mJS);

	var idiv = new ItemDIV();
	idiv.addTo(d3mJS);

	var txt = new ItemText("#00ffff", "rgba(255, 255, 0, 0.1)", 200, 10, "Bold 9px Arial", 12);
	txt.addTo(d3mJS);
	txt.text("adsfsdfbsfb");
	txt.text("В лесу родилась ёлочка, в лесу она росла");
	txt.move(-3, -3, -11);
	//var th=10;
var tree=new ItemConeField(40,170-9);
tree.addTo(d3mJS);
//tree.move(0,-100+9.5,0);
//tree.move(0,-100+15,0);
tree.move(0,-120,0);
	/*
	var dmnd1 = new ItemDiamond3();
	dmnd1.addTo(d3mJS);
	dmnd1.move(-3, 2, -2);

	dmnd1 = new ItemDiamond2();
	dmnd1.addTo(d3mJS);
	dmnd1.move(-3, 2, -11);

	dmnd1 = new ItemDiamond3();
	dmnd1.addTo(d3mJS);
	dmnd1.move(13, -1, -9);
	 */

	//var itemLine;
/*
	for (var i = 0; i < 3; i++) {
		var level = 1.5;
		var r1 = i * Math.PI * 2 / 3.0;
		var r2 = (1 + i) * Math.PI * 2 / 3.0;
		var r3 = r1;
		var r4 = 1 / 6 * Math.PI * 2 + i * Math.PI * 2 / 3.0;
		var r5 = r2;
		var r6 = r1;
		var r7 = 1 / 9 * Math.PI * 2 + i * Math.PI * 2 / 3.0;
		var r8 = 2 / 9 * Math.PI * 2 + i * Math.PI * 2 / 3.0;
		var r9 = r5;
		var r10 = r6;
		var r11 = 1 / 12 * Math.PI * 2 + i * Math.PI * 2 / 3.0;
		var r12 = 2 / 12 * Math.PI * 2 + i * Math.PI * 2 / 3.0;
		var r13 = 3 / 12 * Math.PI * 2 + i * Math.PI * 2 / 3.0;
		var r14 = r9;
		var r15 = r10;
		var r16 = 1 / 15 * Math.PI * 2 + i * Math.PI * 2 / 3.0;
		var r17 = 2 / 15 * Math.PI * 2 + i * Math.PI * 2 / 3.0;
		var r18 = 3 / 15 * Math.PI * 2 + i * Math.PI * 2 / 3.0;
		var r19 = 4 / 15 * Math.PI * 2 + i * Math.PI * 2 / 3.0;
		var r20 = r14;
		//
		maline(new THREE.Vector3(0, 9, 0), new THREE.Vector3(Math.sin(r1), 8, Math.cos(r1)), d3mJS);
		maline(new THREE.Vector3(Math.sin(r1), 8, Math.cos(r1)), new THREE.Vector3(Math.sin(r2), 8, Math.cos(r2)), d3mJS);
		//
		maline(new THREE.Vector3(Math.sin(r1), 8, Math.cos(r1)), new THREE.Vector3(2 * Math.sin(r3), 7, 2 * Math.cos(r3)), d3mJS);
		maline(new THREE.Vector3(2 * Math.sin(r3), 7, 2 * Math.cos(r3)), new THREE.Vector3(2 * Math.sin(r4), 7, 2 * Math.cos(r4)), d3mJS);
		maline(new THREE.Vector3(Math.sin(r1), 8, Math.cos(r1)), new THREE.Vector3(2 * Math.sin(r4), 7, 2 * Math.cos(r4)), d3mJS);
		maline(new THREE.Vector3(Math.sin(r2), 8, Math.cos(r2)), new THREE.Vector3(2 * Math.sin(r4), 7, 2 * Math.cos(r4)), d3mJS);
		maline(new THREE.Vector3(2 * Math.sin(r4), 7, 2 * Math.cos(r4)), new THREE.Vector3(2 * Math.sin(r5), 7, 2 * Math.cos(r5)), d3mJS);
		//
		maline(new THREE.Vector3(2 * Math.sin(r3), 7, 2 * Math.cos(r3)), new THREE.Vector3(3 * Math.sin(r6), 6, 3 * Math.cos(r6)), d3mJS);
		maline(new THREE.Vector3(3 * Math.sin(r6), 6, 3 * Math.cos(r6)), new THREE.Vector3(3 * Math.sin(r7), 6, 3 * Math.cos(r7)), d3mJS);
		maline(new THREE.Vector3(2 * Math.sin(r3), 7, 2 * Math.cos(r3)), new THREE.Vector3(3 * Math.sin(r7), 6, 3 * Math.cos(r7)), d3mJS);
		maline(new THREE.Vector3(2 * Math.sin(r4), 7, 2 * Math.cos(r4)), new THREE.Vector3(3 * Math.sin(r7), 6, 3 * Math.cos(r7)), d3mJS);
		maline(new THREE.Vector3(2 * Math.sin(r4), 7, 2 * Math.cos(r4)), new THREE.Vector3(3 * Math.sin(r8), 6, 3 * Math.cos(r8)), d3mJS);
		maline(new THREE.Vector3(3 * Math.sin(r7), 6, 3 * Math.cos(r7)), new THREE.Vector3(3 * Math.sin(r8), 6, 3 * Math.cos(r8)), d3mJS);
		maline(new THREE.Vector3(2 * Math.sin(r5), 7, 2 * Math.cos(r5)), new THREE.Vector3(3 * Math.sin(r8), 6, 3 * Math.cos(r8)), d3mJS);
		maline(new THREE.Vector3(3 * Math.sin(r9), 6, 3 * Math.cos(r9)), new THREE.Vector3(3 * Math.sin(r8), 6, 3 * Math.cos(r8)), d3mJS);
		//
		maline(new THREE.Vector3(3 * Math.sin(r6), 6, 3 * Math.cos(r6)), new THREE.Vector3(4 * Math.sin(r10), 5, 4 * Math.cos(r10)), d3mJS);
		maline(new THREE.Vector3(3 * Math.sin(r6), 6, 3 * Math.cos(r6)), new THREE.Vector3(4 * Math.sin(r11), 5, 4 * Math.cos(r11)), d3mJS);
		maline(new THREE.Vector3(4 * Math.sin(r10), 5, 4 * Math.cos(r10)), new THREE.Vector3(4 * Math.sin(r11), 5, 4 * Math.cos(r11)), d3mJS);
		maline(new THREE.Vector3(3 * Math.sin(r7), 6, 3 * Math.cos(r7)), new THREE.Vector3(4 * Math.sin(r11), 5, 4 * Math.cos(r11)), d3mJS);
		maline(new THREE.Vector3(4 * Math.sin(r12), 5, 4 * Math.cos(r12)), new THREE.Vector3(4 * Math.sin(r11), 5, 4 * Math.cos(r11)), d3mJS);
		maline(new THREE.Vector3(3 * Math.sin(r7), 6, 3 * Math.cos(r7)), new THREE.Vector3(4 * Math.sin(r12), 5, 4 * Math.cos(r12)), d3mJS);
		maline(new THREE.Vector3(3 * Math.sin(r8), 6, 3 * Math.cos(r8)), new THREE.Vector3(4 * Math.sin(r12), 5, 4 * Math.cos(r12)), d3mJS);
		maline(new THREE.Vector3(3 * Math.sin(r8), 6, 3 * Math.cos(r8)), new THREE.Vector3(4 * Math.sin(r13), 5, 4 * Math.cos(r13)), d3mJS);
		maline(new THREE.Vector3(4 * Math.sin(r12), 5, 4 * Math.cos(r12)), new THREE.Vector3(4 * Math.sin(r13), 5, 4 * Math.cos(r13)), d3mJS);
		maline(new THREE.Vector3(3 * Math.sin(r9), 6, 3 * Math.cos(r9)), new THREE.Vector3(4 * Math.sin(r13), 5, 4 * Math.cos(r13)), d3mJS);
		maline(new THREE.Vector3(4 * Math.sin(r14), 5, 4 * Math.cos(r14)), new THREE.Vector3(4 * Math.sin(r13), 5, 4 * Math.cos(r13)), d3mJS);
		//
		maline(new THREE.Vector3(4 * Math.sin(r10), 5, 4 * Math.cos(r10)), new THREE.Vector3(5 * Math.sin(r15), 4, 5 * Math.cos(r15)), d3mJS);
		maline(new THREE.Vector3(4 * Math.sin(r10), 5, 4 * Math.cos(r10)), new THREE.Vector3(5 * Math.sin(r16), 4, 5 * Math.cos(r16)), d3mJS);
		maline(new THREE.Vector3(5 * Math.sin(r15), 4, 5 * Math.cos(r15)), new THREE.Vector3(5 * Math.sin(r16), 4, 5 * Math.cos(r16)), d3mJS);
		maline(new THREE.Vector3(4 * Math.sin(r11), 5, 4 * Math.cos(r11)), new THREE.Vector3(5 * Math.sin(r16), 4, 5 * Math.cos(r16)), d3mJS);
		maline(new THREE.Vector3(4 * Math.sin(r11), 5, 4 * Math.cos(r11)), new THREE.Vector3(5 * Math.sin(r17), 4, 5 * Math.cos(r17)), d3mJS);
		maline(new THREE.Vector3(5 * Math.sin(r16), 4, 5 * Math.cos(r16)), new THREE.Vector3(5 * Math.sin(r17), 4, 5 * Math.cos(r17)), d3mJS);
		maline(new THREE.Vector3(4 * Math.sin(r12), 5, 4 * Math.cos(r12)), new THREE.Vector3(5 * Math.sin(r17), 4, 5 * Math.cos(r17)), d3mJS);
		maline(new THREE.Vector3(4 * Math.sin(r12), 5, 4 * Math.cos(r12)), new THREE.Vector3(5 * Math.sin(r18), 4, 5 * Math.cos(r18)), d3mJS);
		maline(new THREE.Vector3(5 * Math.sin(r18), 4, 5 * Math.cos(r18)), new THREE.Vector3(5 * Math.sin(r17), 4, 5 * Math.cos(r17)), d3mJS);
		maline(new THREE.Vector3(4 * Math.sin(r13), 5, 4 * Math.cos(r13)), new THREE.Vector3(5 * Math.sin(r18), 4, 5 * Math.cos(r18)), d3mJS);
		maline(new THREE.Vector3(4 * Math.sin(r13), 5, 4 * Math.cos(r13)), new THREE.Vector3(5 * Math.sin(r19), 4, 5 * Math.cos(r19)), d3mJS);
		maline(new THREE.Vector3(5 * Math.sin(r18), 4, 5 * Math.cos(r18)), new THREE.Vector3(5 * Math.sin(r19), 4, 5 * Math.cos(r19)), d3mJS);
		maline(new THREE.Vector3(4 * Math.sin(r14), 5, 4 * Math.cos(r14)), new THREE.Vector3(5 * Math.sin(r19), 4, 5 * Math.cos(r19)), d3mJS);
		maline(new THREE.Vector3(5 * Math.sin(r20), 4, 5 * Math.cos(r20)), new THREE.Vector3(5 * Math.sin(r19), 4, 5 * Math.cos(r19)), d3mJS);
		//var itemLine = new ItemLine(0xff00ff);
		//itemLine.addTo(d3mJS);
		//itemLine.align(new THREE.Vector3(0, 9, 0), new THREE.Vector3(Math.sin(r1), 8, Math.cos(r1)));

		

	}
*/
	var cane = new ItemCane(1, 0x6633ff);
	cane.addTo(d3mJS);
	//diamond.align(new THREE.Vector3(6, 3, 2),new THREE.Vector3(1, 5, 11));
	cane.align(new THREE.Vector3(2, 7, 3), new THREE.Vector3(4, 15, 5));

	var laser = new ItemLaserRay(1, 0x6633ff);
	laser.addTo(d3mJS);
	//diamond.align(new THREE.Vector3(6, 3, 2),new THREE.Vector3(1, 5, 11));
	//laser.align(new THREE.Vector3(5, 0, 0), new THREE.Vector3(0, 9, 0));
	laser.align(new THREE.Vector3(-5, -13, 1), new THREE.Vector3(12, 7, 3));

	var knob1 = new ItemKnob(1, 1, 1, 0xff0000);
	knob1.addTo(d3mJS);
	knob1.move(2, 3, 5);
	knob1.tap = function () {
		new Ticker(d3mJS, 25, 5, 10, function (n) {
			knob1.move(2, 3, n);
		}, function () {
			//console.log("done");
			new Ticker(d3mJS, 25, 10, 5, function (n) {
				knob1.move(2, 3, n);
			}, function () {
				console.log("done");
			}).go();
		}).go();
	};

	var knob2 = new ItemKnob(1, 1, 1, 0x00ff00);
	knob2.addTo(d3mJS);
	knob2.move(1, 0, 0);
	knob2.tap = function () {
		//console.log("2");
		//diamond.align(new THREE.Vector3(10, 0, 0),new THREE.Vector3(0, 5, 2));
	};

	var knob3 = new ItemKnob(1, 1, 1, 0x0000ff);
	knob3.addTo(d3mJS);
	knob3.move(1, 5, 11);
	knob3.tap = function () {
		//console.log("3");
		//diamond.align(new THREE.Vector3(10, 0, 0),new THREE.Vector3(0, 5, 3));
	};

	var globe = new ItemInvertedGlobe(100
	//, "images/GhpCesknPSvNf1FReSqDhQ-23.303391_151.914955.jpg");
	//, 'images/tiles7x7.jpg');
	, 'images/xsshop.jpg');
	globe.addTo(d3mJS);
	globe.move(2, 9, 3);

	var sparkle = new ItemSparkle(13, 0.025, 0xff0000);
	sparkle.addTo(d3mJS);
	sparkle.move(10, 0, 0);

	var sparkle = new ItemSparkle(5, 0.1, 0xffffff);
	sparkle.addTo(d3mJS);
	sparkle.move(10, 0, 0);

	//d3mJS.targetList.push(knob1.cube);
	//d3mJS.targetList.push(knob2.cube);
	//d3mJS.targetList.push(knob3.cube);

	/*
	var geometry = new THREE.BoxGeometry(4, 5, 6);
	var material = new THREE.MeshBasicMaterial({
	color : 0x00ffff
	});
	var cube = new THREE.Mesh(geometry, material);
	d3mJS.scene.add(cube);
	 */

}
